package com.zxsj.fdk.study.controller;

import com.zxsj.fdk.study.common.Result;
import com.zxsj.fdk.study.common.validation.condition.CreateAction;
import com.zxsj.fdk.study.common.validation.condition.UpdateAction;
import com.zxsj.fdk.study.service.check.TestCheckParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * @Description
 * @Author mengweibin
 * @Date 2021-07-06 23:37
 */
@RestController
@RefreshScope
@RequestMapping("/forwarder")
@Api(tags = {"hello控制器"})
public class HelloController {


    @ApiOperation(
            value = "hello方法简要说明",
            notes = "告诉你这个方法是干嘛的",
            response = String.class
    )
    @GetMapping("/hello")
    public String testHello() {
        return "hahahha";
    }

    @ApiOperation("测试校验注解 CreateAction")
    @PostMapping("/create")
    public Result testCheckCreate(@RequestBody @Validated({CreateAction.class}) TestCheckParam param) {
        return Result.ok();
    }

    @ApiOperation("测试校验注解  UpdateAction")
    @PutMapping("/update")
    public Result testCheckUpdate(@RequestBody @Validated({UpdateAction.class}) TestCheckParam param) {
        return Result.ok();
    }

    @ApiOperation("测试校验注解 没有分组")
    @PostMapping("/all")
    public Result testCheckNoGroup(@RequestBody @Valid TestCheckParam param) {
        return Result.ok();
    }


    @ApiOperation("提供给 goods调用接口")
    @GetMapping("/test/fegin")
    public Result testFegin() {
        return Result.ok("fegin调用成功！");
    }


}

